/*
 *Description:
 *User:laoHu
 *Created with Intellij IDEA 2025
 *Data:2025.05.26
 *Time:00:14:10
 */

import java.util.Arrays;

//类和对象
public class Main {

    //构成方法
    public static void main(String[] args) {

        //创建对象
       myData data1 = new myData();
       // myData data2 = new myData(2022,6,7);

        //使用对象
//        data1.printData();
//        data2.printData();

        //使用对象

        System.out.println(data1);
     //   System.out.println(data2);

    }

    public static void main6(String[] args) {
      //创建一个Gog的对象
        Dog dog1 = new Dog();
        Dog dog2 = new Dog();
        //成员访问：使用.
        dog1.name = "wanCai";
        dog1.age = 7;
        dog2.name = "laiHu";
        dog2.age = 3;

        //观察行为
        System.out.print(dog1.name + ": ");
        dog1.bark();
        System.out.print(dog2.name + ": ");
        dog2.sleep();

    }


    //类和对象的使用
    public static void main5(String[] args) {
        //参加类指向的对象
        WashMachine w = new WashMachine();
        WashMachine w1 = new WashMachine();

        //实例化访问对象的成员
        w.brand = "daLing";
        w.color = "white";
        w.type = "sss";
        w.length = 50.00;
        w.height = 85.50;
        w.weight = 15.00;

        //使用类的功能
        w.wash();
        w.dry();
        w.time();
    }

    //二维数组的使用
    public static void main4(String[] args) {
        int[][] arr = {{1,2,3},{4,5,6}};//2行3列
        int[][] array1 = new int[2][3];
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.print(arr[i][j] + " ");
            }
            System.out.println();
        }
        for(int[] i : array1){
            for(int j : i){
                System.out.print(j + " ");
            }
            System.out.println();
        }

    }

    //数组的应用
    //Array
    //排序
   static int val = 1;
    public static void main3(String[] args) {
        int[] array1 = {10,9,8,7,6,5,4,3,2,1};
        Arrays.sort(array1);//排序
        for (int i = 0; i < array1.length; i++) {
            System.out.print(array1[i] + " ");
        }
        System.out.println();

        int[] array2 = new int[10];

         Arrays.setAll(array2,n -> val++);
        System.out.println(Arrays.toString(array2));
    }


    //求斐波那契数列
    public static int[] fib()
    {
       int[] fib = new int[20];
       fib[1] = 1;
       fib[2] = 1;
        for (int i = 3;  i <fib.length ;i ++) {
            fib[i] = fib[i - 1] + fib[i - 2];
        }
        return fib;
    }

    public static void main2(String[] args) {

        int[] array = fib();
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
    }


    public static void main1(String[] args) {
        //数组的创建和初始化
        //1.创建的同时赋值
        int[] arr1 = {1,2,3,4,5,6};

        //2.开辟一个新的空间
        int[] arr2 = new int[6];
        //通过for循环初始化
        for (int i = 0; i < 6; i++) {
            arr2[i] = i + 1;
        }

        //3.开辟新的空间同时初始化
        int[] arr3 = new int[]{1,2,3,4,5,6};

        //数组的输出
        //1.for循环遍历数组
        for (int i = 0; i < arr1.length; i++) {
            System.out.print(arr1[i] + " ");
        }
        System.out.println();

        //2.for each循环遍历
        for(int x : arr2){
            System.out.print(x + " ");
        }
        //换行
        System.out.println();

        //toString输出
       String arr = Arrays.toString(arr3);
        System.out.println(arr);
     }
}